import axios from 'axios'
axios.defaults.baseURL = '/api'

const post = async (url, data) => {
  return new Promise((resolve, reject) => {
    axios.post(url, data).then(
      (res) => {
        resolve(res)
      },
      (err) => {
        reject(err)
      }
    )
  })
}
const get = async (url, data = {}) => {
  return new Promise((resolve, reject) => {
    axios.get(url, { params: data }).then(
      (res) => {
        resolve(res)
      },
      (err) => {
        reject(err)
      }
    )
  })
}
// const put = async (url, data = {}) => {
//   return new Promise((resolve, reject) => {
//     axios({
//       url,
//       method: 'put',
//       data
//     })
//   })
// }
export { post, get }
